#ifndef _WEBPAGE_H_
#define _WEBPAGE_H_

#include "SplitTool.h"
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tinyxml2.h>
#include <vector>

using std::map;
using std::set;
using std::string;
using std::vector;

// 传入html的string，将其解析，提取 docid，title，url，content，hash
class WebPage {
    const static int TOPK_NUMBER = 20;

  public:
    WebPage() {};
    WebPage(int, size_t, size_t, SplitTool *);

    int getDocid();
    string getTitle();
    string getSummary();
    string getUrl();

    map<string, int> &getWordsMap(); // 获取文档的词频统计 map

  private:
    void loadPage(int, size_t, size_t);
    void processDoc(); // 对格式化文档进行处理

  private:
    int _docid;
    string _docTitle;
    string _docUrl;
    string _docContent;
    string _docSummary;
    SplitTool *_cuttor;
    vector<string> _topWords;   // 每篇文章词频最高的前20词
    map<string, int> _wordsMap; // 每篇文章所有词语和词频
};

#endif